//
//  ZYMainViewController.swift
//  weibo
//
//  Created by mac on 16/6/22.
//  Copyright © 2016年 itcast. All rights reserved.
//

import UIKit

class ZYMainViewController: UITabBarController {

//    init(){
//        
//        
//        guard  var a: UITabBarController = UITabBarController() else{
//        
//        
//           return
//        }
//        
//       
//        
//      
//      return a
//        
//        super.init()
//    }
//
//    required init?(coder aDecoder: NSCoder) {
//        fatalError("init(coder:) has not been implemented")
//    }
//    
    override func viewDidLoad() {
        super.viewDidLoad()

//        self.tabBar.tintColor = UIColor.orangeColor()
        
        self.addAnyViewController(ZYTHomeViewController(), title: "主页", imgName: "tabbar_home")
        
        self.addAnyViewController(ZYMessageViewController(), title: "消息", imgName: "tabbar_message_center")
        self.addAnyViewController(ZYDiscoverViewController(), title: "发现", imgName: "tabbar_discover")
        self.addAnyViewController(ZYProfileViewController(), title: "我", imgName: "tabbar_profile")
        
    }
    
    func addAnyViewController(vc: UITableViewController,title: String,imgName: String){
        
        
        
        vc.tabBarItem.title = title
//        vc.tabBarController?.tabBar.tintColor = UIColor.whiteColor()
        
        vc.tabBarItem.image = UIImage(named: imgName)?.imageWithRenderingMode(UIImageRenderingMode.AlwaysOriginal)
        
        vc.tabBarItem.selectedImage = UIImage(named: "\(imgName)_selected")?.imageWithRenderingMode(UIImageRenderingMode.AlwaysOriginal)
        
        
        let nav = UINavigationController(rootViewController: vc)
        
        vc.navigationItem.title = title
    
        self.addChildViewController(nav)
        
    
       
    
    }
    
    
    
    
    
    

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    

    /*
    // MARK: - Navigation

    // In a storyboard-based application, you will often want to do a little preparation before navigation
    override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
        // Get the new view controller using segue.destinationViewController.
        // Pass the selected object to the new view controller.
    }
    */

}
